<?php
$db=new PDO('mysql:host=localhost;dbname=db', 'root','12qwas');
$db->exec("create database if not exists db3");
$db->exec("use db3");
$db->exec("create table if not exists students(xh varchar(9) primary key,name varchar(50),age int default 0)");
$r=$db->exec("delete from students where age>18");
echo "成功删除年龄大于18的{$r}记录~\n";
$r=$db->exec("truncate table students");
var_dump($r);
$r=$db->exec("insert into students(xh,name,age) values('233110120','杰杰',19),('233110118','刘凯鑫',19),('233110119','刘乐',19)");
echo "成功插入了{$r}条数据~\n";
$r=$db->exec("update students set name='毛豪杰' where xh='233110120'");
echo "成功修改了{$r}条数据~\n";
$r=$db->exec("update students set name='DMH' where xh='233110118'");
echo "成功修改了{$r}条数据~\n";